import { createRouter,createWebHistory} from 'vue-router'
const router=createRouter({
    history:createWebHistory(),
    routes:[
        {
            path:'/',
            redirect:'/home',
            meta:{ title:'首页'}
        },
        {
            path:'/home',
            component:()=>import('../pages/Home.vue'),
            name:'home',
            meta:{ title:'首页',name:'home',isTab:true}
        },
        {
          path:'/category',
          component:()=>import('../pages/Category.vue'),
          name:'category',
          meta:{ title:'分类',isShowNav:true,isTab:true}
        },
        {
          path:'/cart',
          component:()=>import('../pages/Cart.vue'),
          name:'cart',
          meta:{ title:'购物车',isShowNav:true,isTab:true,isShowBack:true}
        },
        {
          path:'/user',
          component:()=>import('../pages/User.vue'),
          name:'user',
          meta:{ title:'我的',isTab:true}

        }
    ]
  })
  router.beforeEach((to,from,next)=>{
    const title=to.meta && to.meta.title
    if(title){
      document.title=title+'-微商城'
    }
    next()
  })
  export default router